package com.example.mvp.biz;

import com.example.mvp.bean.User;

/**
 * user 的登录逻辑
 */
public class UserBiz implements IUserBiz {
    // 重写 IUserBiz 中的方法
    @Override
    public void login(final String username, final String password, final OnLoginListener loginListener) {
      new Thread(){
          @Override
          public void run() {
              try {
                  Thread.sleep(2000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              // 模拟登录成功
              if ("liqianjin".equals(username) && "123456".equals(password)){
                  User user = new User();
                  user.setUsername(username);
                  user.setPassword(password);
                  loginListener.loginSuccess(user);
              }else {
                  loginListener.loginFailed();
              }
          }
      }.start();
    }
}
